package com.david.cloud.code.controller;


import com.david.cloud.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author david
 * @since 2020-05-24
 */
@RestController
@RequestMapping("/code")
public class AuthCodeController {

    @Autowired
    private CodeService codeService;

    @RequestMapping("/create/{email}")
    public Boolean create(@PathVariable String email) {
        return codeService.create(email);
    }


    //校验验证码是否正确， 0正确1错误2超时
    @RequestMapping("/validate/{email}/{code}")
    public Integer validate(@PathVariable String email, @PathVariable String code) {
        return codeService.validate(email, code);
    }
}
